﻿
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Service.IService.ISysService;

namespace DevProtocolApi.Controllers.sysControllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RouteInfoController : BaseController
    {
        private readonly IRouteInfoService _routeInfoService;
        private readonly ILogger<RouteInfoController> _logger;

        public RouteInfoController(IRouteInfoService routeInfoService, ILogger<RouteInfoController> logger)
        {
            _routeInfoService = routeInfoService;
            _logger = logger;
        }

        /// <summary>
        /// 获取所有API路由信息
        /// </summary>
        [HttpGet]
        public IActionResult GetAllRoutes()
        {
            try
            {
                var routes = _routeInfoService.GetAllRouteInformations();
                return Success(routes);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "获取部门树失败");
                return Failed($"查询失败: {ex.Message}");
            }
        }
    }
}